package com.lagou.controller;

import com.lagou.pojo.Goods;
import com.lagou.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 *
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @RequestMapping("/findById/{id}")
    public Goods findGoodsById(@PathVariable Integer id){
        System.out.println(1);
        Goods productById = goodsService.findGoodsById(id);
        return productById;
    }

    @RequestMapping("/deleteById/{id}")
    public Integer deleteGoodsById(@PathVariable Integer id){
        int i = goodsService.deleteGoodsById(id);
        return i;
    }

    @RequestMapping("/update")
    public void updateGoodsById(Goods goods){

        int i = goodsService.updateGoodsById(goods);
        System.out.println(i);
    }

    @RequestMapping("/findByPage")
    public Map<List,Integer> selectProductByPage(Integer page,String name,
              String classify,Integer pricemin,Integer pricemax,Integer inventorymin,
    Integer inventorymax,String status){


        Map<List,Integer> map = goodsService.selectGoodsByPage(page,name,classify,pricemin,pricemax,inventorymin,inventorymax,status);
        return map;
    }

}
